import {request,post} from "@/utils/request";
import ApiResult from "@/api/base/ApiResult";
import {ElMessage} from "element-plus";

export function useDeleteGoods() {
  const deleteGoods = async (url: string, params: {id: null | number}) => {
    const rs:ApiResult<any> = await request(url, params)

    if (rs.code === 200) {
      ElMessage.success('删除成功')
    }
  }

  const handleGoodsDelete = (url: string, data: any, listRef:any) => {
    deleteGoods(url, {id: data.id})
      .then(() => {
        listRef.value?.refreshList()
      })
  }

  return {
    handleGoodsDelete,
    // deleteGoods
  }
}
